package com.poh.service.impl;

import com.poh.mapper.ReplyMapper;
import com.poh.pojo.Reply;
import com.poh.service.ReplyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDate;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import java.util.List;
@Service
public class ReplyServiceImpl implements ReplyService {
    @Autowired
    ReplyMapper replyMapper;
    @Override
    public int addReply(Reply reply) {
        LocalDate localDate = LocalDate.now();
        LocalTime localTime = LocalTime.now();
        reply.setReplyTime(localDate.format(DateTimeFormatter.ISO_DATE) + " " + localTime);
        return replyMapper.addReply(reply);
    }

    @Override
    public List<Reply> queryReplyByTopicId(int topicId) {
        return replyMapper.queryReplyByTopicId(topicId);
    }

    @Override
    public List<Reply> queryAllReplyByTopicId(int topicId) {
        return replyMapper.queryAllReplyByTopicId(topicId);
    }

    @Override
    public Reply queryReplyByReplyedId(int replyedId) {
        return replyMapper.queryReplyByReplyedId(replyedId);
    }

    @Override
    public int deleteReplyById(int replyId) {
        return replyMapper.deleteReplyById(replyId);
    }

    @Override
    public List<Reply> queryReplyByUserId(int userId) {
        return replyMapper.queryReplyByUserId(userId);
    }

    @Override
    public List<Reply> queryReplyedByReplyedName(String userName) {
        return replyMapper.queryReplyedByReplyedName(userName);
    }
}
